package com.cdream.basic.algorithm.leetcode.sort;

import cn.hutool.json.JSONUtil;

/**
 * @author cdream
 * @date 7/4/21
 */
public class Question645 {
    public int[] findErrorNums(int[] nums) {
        int[] bucket = new int[10001];
        for(int num : nums){
            bucket[num]++;
        }
        int [] res = new int[2];
        for(int i = 1; i<bucket.length;i++){
            if(bucket[i]==0){
                res[1] = i;
            }
            if(bucket[i]>1){
                res[0] = i;
            }
            if(res[1]!=0 && res[0]!=0){
                return res;
            }
        }
        return null;
    }

    public static void main(String[] args) {
        int[] errorNums = new Question645().findErrorNums(new int[]{2, 2});
        System.out.println(JSONUtil.toJsonPrettyStr(errorNums));
    }
}
